import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:nested/nested.dart';
import '../ability/NavigatorUtil.dart' as navigator;
import '../base_provider.dart';

//导航实现
mixin NavigatorActionMixin<T extends StatefulWidget> on State<T> {
  Future<dynamic> gotoWidgetSingleProvider<T extends CunwControllNotify>(
      Widget widget,
      {String routeName,
      T value}) {
    return navigator.gotoWidgetSingleProvider(context, widget,
        routeName: routeName, value: value);
  }

  Future<dynamic> gotoWidget(Widget widget,
      {String routeName, List<SingleChildWidget> providers}) {
    return navigator.gotoWidget(context, widget,
        routeName: routeName, providers: providers);
  }

  Future<dynamic> replaceWidget(Widget widget,
      {String routeName, List<SingleChildWidget> providers}) {
    return navigator.replaceWidget(context, widget,
        routeName: routeName, providers: providers);
  }

  void popToWidget(String routeName) {
    navigator.popToWidget(context, routeName);
  }

  void popToHome() {
    navigator.popToHome(context);
  }

  void popAllToWidget(Widget widget,
      {String routeName, List<SingleChildWidget> providers}) {
    navigator.popAllToWidget(context, widget,
        routeName: routeName, providers: providers);
  }

  void popWidget({dynamic obj}) {
    navigator.popWidget(context, obj: obj);
  }
}
mixin NavigatorActionMixin2 {
  Future<dynamic> gotoWidgetSingleProvider<T extends CunwControllNotify>(
      Widget widget,
      {String routeName,
      T value}) {
    return navigator.gotoWidgetSingleProvider(navigatorContext, widget,
        routeName: routeName, value: value);
  }

  Future<dynamic> gotoWidget(Widget widget,
      {String routeName, List<SingleChildWidget> providers}) {
    return navigator.gotoWidget(navigatorContext, widget,
        routeName: routeName, providers: providers);
  }

  Future<dynamic> replaceWidget(Widget widget,
      {String routeName, List<SingleChildWidget> providers}) {
    return navigator.replaceWidget(navigatorContext, widget,
        routeName: routeName, providers: providers);
  }

  void popToWidget(String routeName) {
    navigator.popToWidget(navigatorContext, routeName);
  }

  void popToHome() {
    navigator.popToHome(navigatorContext);
  }

  void popAllToWidget(Widget widget,
      {String routeName, List<SingleChildWidget> providers}) {
    navigator.popAllToWidget(navigatorContext, widget,
        routeName: routeName, providers: providers);
  }

  void popWidget({dynamic obj}) {
    navigator.popWidget(navigatorContext, obj: obj);
  }
}
